package so.sao.code.service.service;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;

import so.sao.code.dto.request.CodeAvailableTypeRequest;
import so.sao.code.dto.request.TagBatchCreate;
import so.sao.code.dto.request.TerminalDownloadRequest;
import so.sao.code.dto.response.AvailableNum;
import so.sao.code.dto.response.TagAvailableTypeDto;
import so.sao.code.dto.response.TagBatchPrintFileDto;
import so.sao.code.dto.response.TerminalDownloadResponse;
import so.sao.code.service.domain.entity.TagBatch;
import so.sao.code.service.infrastructure.model.vo.TagBatchPrintFormatVO;
import so.sao.code.service.infrastructure.model.vo.TagBatchVO;
import so.sao.code.service.infrastructure.model.vo.TagMetaVO;
import so.sao.top.core.util.rest.RestException;

public interface TagBatchService {

	List<Long> create(TagBatchCreate tagBatchCreate);

	/**
	 * 按照批次id查找标签批次信息
	 *
	 * @param tagBatchId
	 * @return
	 */
	// public TagBatch findOne(Long tagBatchId);
	public Page<TagBatch> findTagBatches(Specification<TagBatch> spec, Pageable pageable);

	/**
	 * 保存批次及可用码段信息
	 *
	 * @param tagBatches
	 * @param lookupTable
	 * @return
	 */
	// public Iterable<TagBatch> saveTagBatches(List<TagBatch> tagBatches,
	// LookupTable lookupTable);

	/**
	 * 依据顶级企业id查找已经生成的标签数量
	 *
	 * @param eseId
	 * @return
	 */
	// public long findCreatedCountByMasterEseId(Long eseId);
	public List<TagBatchPrintFormatVO> findTagBatchConfigs(Long eseId, int type);
    /**
     * 下载指定批次的印刷文件
     *
     * @param tagBatchId
     * @return
     */
//    public String downloadTagBatchPrintFile(Long tagBatchId);
    
    /**
     * 下载指定批次的印刷文件
     *
     * @param tagBatchId
     * @return
     */
    public void downloadFile(Long tagBatchId, HttpServletResponse response);

	/**
	 * 按企业下载已生成印刷文件但没有被下载过的批次
	 *
	 * @param eseID
	 * @return
	 */
	public TagBatchPrintFileDto downloadTagBatchPrintFileByEseId(Long eseId, int downloadMethod);

	/**
	 * 获取标签元数据
	 */
	TagMetaVO getTagMeta();

	/**
	 * 列表数据拼凑
	 */
	List<TagBatchVO> buildTagBatchVO(List<TagBatchVO> list) throws RestException;

	Long CodeCount(long eseId);

	List<TagBatchVO> findTagBatchesBytagBatchIdOrName(Specification<TagBatch> spec);

	TagBatch find(Long tagBatchId);

	List<TagAvailableTypeDto> getAvailableTypeByTerminalId(Long terminalId,Long eseId);

 
	TerminalDownloadResponse downloadByTerminal(TerminalDownloadRequest terminalDownloadRequest,Long terminalId,Long eseId) throws Exception;
	public String getFileNameByTagBatchId(Long tagBatchId);

	void updateTerminalDownload(Long successID) throws Exception;

	AvailableNum getAvailableNum(String terminalId,Integer tagType,Long eseId);

}
